var t = getApp();

Page({
    data: {
        fileList: [],
        uploadUrl: "upload.uploadPic",
        reportContentShow: !0,
        room_id: "",
        liveReportData: "",
        radio: "1",
        desc: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            room_id: t.id
        }), this.getLiveReport();
    },
    descInp: function(t) {
        var a = t.detail.value;
        this.setData({
            desc: a
        });
    },
    submit: function() {
        if (!this.data.desc) return wx.showToast({
            icon: "none",
            title: "请填写问题描述",
            duration: 1500
        }), !1;
        if (this.data.fileList.length <= 0) return wx.showToast({
            icon: "none",
            title: "请上传相关截图",
            duration: 1500
        }), !1;
        var a = this, o = t.getNetAddresss("plugin.room.frontend.live.report-add");
        t._postNetWork({
            url: o,
            showToastIn: !1,
            data: {
                room_id: this.data.room_id,
                report_type: Number(this.data.radio),
                desc: this.data.desc,
                image: this.data.fileList
            },
            success: function(t) {
                var o = t.data;
                1 == o.result ? (wx.showToast({
                    icon: "none",
                    title: "消息提交成功",
                    duration: 1500
                }), a.setData({
                    reportContentShow: !1
                })) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onChange: function(t) {
        var a = t.detail;
        this.setData({
            radio: a
        });
    },
    getLiveReport: function() {
        var a = this, o = t.getNetAddresss("plugin.room.frontend.live.report");
        t._postNetWork({
            url: o,
            showToastIn: !1,
            data: {
                room_id: this.data.room_id
            },
            success: function(t) {
                var o = t.data;
                1 == o.result ? a.setData({
                    liveReportData: o.data
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    returnBtn: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    removeImg_1: function(t) {
        var a = t.currentTarget.dataset.index, o = this.data.fileList, e = this.data.infoArr;
        o.splice(a, 1), this.setData({
            fileList: o,
            infoArr: e
        });
    },
    onRead_2: function() {
        if (4 == this.data.upNumMaxOther || this.data.upNumMaxOther >= 4) return wx.showToast({
            icon: "none",
            title: "图片数量已达到上限",
            duration: 1500
        }), !1;
        var a = this, o = t.getNetAddresss(this.data.uploadUrl);
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var e = t.tempFilePaths;
                wx.compressImage({
                    src: e[0],
                    quality: 60,
                    success: function(t) {
                        var e = t.tempFilePath;
                        wx.uploadFile({
                            url: o,
                            filePath: e,
                            name: "file",
                            formData: {
                                attach: "upload"
                            },
                            success: function(t) {
                                var o = JSON.parse(t.data);
                                if (1 == o.result) {
                                    var e = a.data.fileList;
                                    e.push({
                                        url: o.data.img_url
                                    }), a.setData({
                                        upNumMaxOther: a.data.upNumMaxOther + 1,
                                        fileList: e
                                    });
                                } else wx.showToast({
                                    icon: "none",
                                    title: o.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                });
            }
        });
    }
});